<template>
	<view>
		<view class="title">
			<image @click="fanhui" src="/static/hjt.png" :style="'padding-top:'+top+'px;'" mode=""></image>
			<view class="toptit" :style="'padding-top:'+top+'px;'">
				我的工单
			</view>
			<view class="" style="opacity: 0;">12</view>
		</view>
		<view class="tab">
			<view :class="stater==1?'tab2':'tab1'" @click="tab(1)">
				待受理
			</view>
			<view :class="stater==2?'tab2':'tab1'" @click="tab(2)">
				维修中
			</view>
			<view :class="stater==3?'tab2':'tab1'" @click="tab(3)">
				已完成
			</view>
			<view class="tab1" @click="datetime">
				日期
				<image src="../../static/sjx1.png" mode=""></image>
			</view>
		</view>
		<view class="center">
			<view class="box" v-for="(item,index) in gdlist" :key="index">
				<view class="box_title">
					{{item.communityName}}{{item.roomName}}
					<!-- <image class="topimg" src="../../static/jx8.png" mode=""></image> -->
					<view :class="'topimg'+stater">
						{{item.formatstatus}}
					</view>
				</view>
				<view class="box_2">
					<view class="box_2text">
						报修人： <text>{{item.name}}</text>
					</view>
					<view class="box_2text">
						报修时间：<text>{{item.ctime}}</text>
					</view>
					<view class="box_2text">
						报修类型： <text>{{item.protitle}}</text>
					</view>
				</view>
				<view class="buttom">
					<view v-if="item.btns[0]" :class="'buttom1'+stater" @click="info(item.id)">
						{{item.btns[0]}}
					</view>
					<view v-if="item.btns[1]" :class="'buttom2'+stater" @click="godoor(item.id)">
						{{item.btns[1]}}
					</view>
				</view>
			</view>

		</view>
		<uni-datetime-picker style="opacity: 0;" ref="picker" :end="endDate" v-model="range" type="daterange"
			@change="maskClick">
			<div></div>
		</uni-datetime-picker>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				top: 0,
				timedate: '',
				stater: 1,
				nextp: 1,
				gdlist: [],
				range: [],
				endDate: ''
			}
		},
		watch: {
			range(newval) {
				console.log('范围选:', this.range);
				this.timedate = this.range[0] + ' ' + this.range[1]
				console.log(this.timedate);
				this.nextp = 1
				this.getlist()
			},
		},
		onLoad() {
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			// this.CustomBar = menuButtonInfo.bottom * 1 + 10
			this.top = menuButtonInfo.top * 1 + 6
			this.getDate()
		},
		onShow() {
			this.getlist()
		},

		methods: {
			datetime() {
				this.$refs.picker.show()
			},
			tab(e) {
				this.stater = e
				this.nextp = 1
				this.getlist()
			},
			maskClick(e) {
				console.log('mask', e);
			},
			info(id) {
				uni.navigateTo({
					url: '/pages/gongdan/mygongdaninfo?id=' + id
				})
			},
			getlist() {
				if (this.nextp) {
					this.$post('wuyecenter/getmybaoxiu', {
						p: this.nextp,
						status: this.stater,
						datetime: this.timedate,

					}, res => {
						if (this.nextp == 1) {
							this.gdlist = res.data.list
						} else {
							res.data.list.forEach(item => {
								this.gdlist.push(item)
							})
						}
						this.nextp = res.data.nextp
					})
				}

			},
			godoor(id) {
				if (this.stater == 2) {
					uni.navigateTo({
						url: '/pages/gongdan/gongdan?id=' + id
					})
				} else {
					this.$post('wuyecenter/enterloc', {
						id: id
					}, res => {
						this.nextp = 1
						this.getlist()
					})
				}


			},
			bindDateChange(e) {
				this.date = e.detail.value
			},
			fanhui() {
				uni.navigateBack({
					delta: 1
				})
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					// year = year + 2;
				}
				month = month > 9 ? month : '0' + month;
				day = day > 9 ? day : '0' + day;
				this.endDate = `${year}-${month}-${day}`;
				console.log(this.endDate, 'shijian');
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #ffffff;
	}

	.title {
		background-color: #ffffff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 30rpx;

		>image {
			width: 20rpx;
			height: 35rpx;
			margin-left: 30rpx;
		}
	}

	.toptit {
		font-size: 36rpx;
		font-family: Source Han Sans CN;
		font-weight: 600;
		color: #000000;
		line-height: 20rpx;
	}

	.tab {
		display: flex;
		justify-content: space-evenly;
		align-content: center;
	}

	.tab2 {
		font-size: 30rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #000000;
		line-height: 80rpx;
		border-bottom: #2d75fc solid 2px;
	}

	.tab1 {
		font-size: 30rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #000000;
		line-height: 80rpx;
		border-bottom: #ffffff solid 2px;
		display: flex;
		align-items: center;

		>image {
			margin-left: 10rpx;
			width: 21rpx;
			height: 15rpx;
		}
	}

	.box {
		width: 700rpx;
		margin: 20rpx auto;
		padding: 20rpx 0;
		box-shadow: 0px 0px 20px 0 #f5f5f5;
	}

	.box_title {
		// border-left: 8rpx solid #4ab6f9;
		// width: 180rpx;
		// text-align: center;
		width: 91%;
		margin: 0 auto;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: bold;
		color: #000000;
		line-height: 28rpx;
		// line-height: 20rpx;
	}

	.box_2 {
		width: 91%;
		margin: 30rpx auto;
		border-bottom: #e2e2e2 solid 2rpx;
	}

	.box_2text {
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #999999;
		// line-height: 20rpx;
		margin: 30rpx 0;

		>text {
			color: #999999;
		}
	}

	.topimg1 {
		position: absolute;
		background-image: url('../../static/jx8.png');
		background-size: 123rpx;
		margin-top: -50rpx;
		text-align: center;
		right: 26rpx;
		width: 123rpx;
		height: 41rpx;
		font-size: 20rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 41rpx;
	}

	.topimg2 {
		position: absolute;
		background-image: url('../../static/jx7.png');
		background-size: 123rpx;
		margin-top: -50rpx;
		text-align: center;
		right: 26rpx;
		width: 123rpx;
		height: 41rpx;
		font-size: 20rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 41rpx;
	}

	.topimg3 {
		position: absolute;
		background-image: url('../../static/jx.png');
		background-size: 123rpx;
		margin-top: -50rpx;
		text-align: center;
		right: 26rpx;
		width: 123rpx;
		height: 41rpx;
		font-size: 20rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #2D75FC;
		line-height: 41rpx;
	}


	.texta {
		width: 91%;
		height: 170rpx;
		margin: 0 auto;
		background-color: #f6f6f6;
	}

	.buttom {
		display: flex;
		justify-content: flex-end;
		overflow: hidden;
	}

	.buttom11 {
		width: 122rpx;
		height: 50rpx;
		border: #2d75fc solid 2px;
		color: #2d75fc;
		text-align: center;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #2E79FC;
		line-height: 50rpx;
		border-radius: 10rpx;
	}

	.buttom12 {
		width: 122rpx;
		height: 50rpx;
		border: #61d6c6 solid 2px;
		color: #61d6c6;
		text-align: center;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #61d6c6;
		line-height: 50rpx;
		border-radius: 10rpx;
	}

	.buttom13 {
		width: 122rpx;
		height: 50rpx;
		border: #e8f1ff solid 2px;
		color: #e8f1ff;
		text-align: center;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		color: #2D75FC;
		line-height: 50rpx;
		border-radius: 10rpx;
	}

	.buttom21 {
		margin: 0 20rpx;
		width: 122rpx;
		height: 50rpx;
		background-color: #49b5f9;
		border: #49b5f9 solid 2px;
		color: #ffffff;
		text-align: center;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		line-height: 50rpx;
		border-radius: 10rpx;
	}

	.buttom22 {
		margin: 0 20rpx;
		width: 122rpx;
		height: 50rpx;
		background-color: #61d6c6;
		border: #61d6c6 solid 2px;
		color: #ffffff;
		text-align: center;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		line-height: 50rpx;
		border-radius: 10rpx;
	}

	.buttom23 {
		margin: 0 20rpx;
		width: 122rpx;
		height: 50rpx;
		background-color: #e8f1ff;
		border: #e8f1ff solid 2px;
		color: #2D75FC;
		text-align: center;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		line-height: 50rpx;
		border-radius: 10rpx;
	}
</style>
